﻿@{
    ViewBag.Title = "ListLog";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}
@section head{
    <script type="text/javascript">
        function GotoPage(day, page) {
            location.href = '/Log/ListLog?day=' + day + '&page=' + page;
        }

        function button6click() {
            var textday = document.getElementById("textday");
            var textpagenumber = document.getElementById("textpagenumber");
            var texttotalpagenumber = document.getElementById("texttotalpagenumber");
            if (textpagenumber.value == texttotalpagenumber.value || texttotalpagenumber.value == 0) {
                return false;
            }
            else {
                GotoPage(textday.value, parseInt(textpagenumber.value) + 1);
            }
        }

        function button3click() {
            var textday = document.getElementById("textday");
            var textpagenumber = document.getElementById("textpagenumber");
            var texttotalpagenumber = document.getElementById("texttotalpagenumber");
            if (textpagenumber.value == 1 || texttotalpagenumber.value == 0) {
                return false;
            }
            else {
                GotoPage(textday.value, parseInt(textpagenumber.value) - 1);
            }
        }
    </script>
}
@using PagedList.Mvc;
@using ATM;
<div id="Content">
    <h3 style="color: white">View transaction history</h3>
    @{PagedList.PagedList<ATM.Models.Log> _pagelistLog = (PagedList.PagedList<ATM.Models.Log>)ViewData[StaticValue.KEY_LIST_LOGS];}
    @{int day = (int)ViewData[StaticValue.KEY_DAY];}
    <div style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: white; width: 100%; height: 80%">
        <table border="1" style="width: 100%;">
            <tr style="background-color: gray; color: white; text-align: center; font-size: medium; height:30px">
                <td>
                    ATM(Location)
                </td>
                <td>
                    Type
                </td>
                <td>
                    Date
                </td>
                <td>
                    Amount
                </td>
                <td>
                    To
                </td>
            </tr>
            @if (_pagelistLog.Count == 0)
            {
                <tr>
                    <td colspan="5" style="text-align: center">
                        Not data!
                    </td>
                </tr>
            }
            else
            {
                int currentrow = 0;
                foreach (ATM.Models.Log item in _pagelistLog)
                {
                    @*to mau dong le*@
                    if (currentrow % 2 == 1)
                    {
                        <tr style="font-size: small; background-color: gray">
                            <td>
                                @item.ATM.Address
                            </td>
                            <td>
                                @item.LogType.Description
                            </td>
                            <td>
                                @item.LogDate.Value.ToShortDateString()
                            </td>
                            <td style="text-align: right">
                                @item.Amount.NumberFormat()
                            </td>
                            <td>
                                @item.AccountReceiver
                            </td>
                        </tr>
                    }
                    else
                    {
                        <tr style="font-size: small">
                            <td>
                                @item.ATM.Address
                            </td>
                            <td>
                                @item.LogType.Description
                            </td>
                            <td>
                                @item.LogDate.Value.ToShortDateString()
                            </td>
                            <td style="text-align: right">
                                @item.Amount.NumberFormat()
                            </td>
                            <td>
                                @item.AccountReceiver
                            </td>
                        </tr>
                    }
                    currentrow++;
                }
            }
        </table>
    </div>
    <table style="width: 100%; height: 10%; bottom: 0px; border-spacing: 0px">
        <tr style="height: 100%">
            <td style="height: 100%">
                @*neu la trang dau thi ko hien nut quay lai*@
                @if (_pagelistLog.PageNumber != 1)
                {
                    <input type="button" value="Previous" onclick="return button3click();" style="width: 100px; height: 100%" class="buttonleft" />
                }
            </td>
            <td style="text-align: right">
                @*neu la trang cuoi thi ko hien nut tiep theo*@
                @if (_pagelistLog.PageNumber != _pagelistLog.PageCount)
                {
                    <input type="button" value="Next" onclick="return button6click();" style="width: 100px; height: 100%" class="buttonright" />
                }
            </td>
        </tr>
    </table>
    <input type="text" id="textday" value="@day" style="display: none" />
    <input type="text" id="textpagenumber" value="@_pagelistLog.PageNumber" style="display: none" />
    <input type="text" id="texttotalpagenumber" value="@_pagelistLog.PageCount" style="display: none" />
</div>
